/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author corneliugosa
 */
@Entity
@Table(name = "upload")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Upload.findAll", query = "SELECT u FROM Upload u")})
public class Upload implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Column(name = "file")
    private byte[] file;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idUpload")
    private List<ToDoHomework> toDoHomeworkList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idUpload")
    private List<Course> courseList;

    public Upload() {
    }

    public Upload(Integer id) {
        this.id = id;
    }

    public Upload(Integer id, byte[] file) {
        this.id = id;
        this.file = file;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public byte[] getFile() {
        return file;
    }

    public void setFile(byte[] file) {
        this.file = file;
    }

    @XmlTransient
    public List<ToDoHomework> getToDoHomeworkList() {
        return toDoHomeworkList;
    }

    public void setToDoHomeworkList(List<ToDoHomework> toDoHomeworkList) {
        this.toDoHomeworkList = toDoHomeworkList;
    }

    @XmlTransient
    public List<Course> getCourseList() {
        return courseList;
    }

    public void setCourseList(List<Course> courseList) {
        this.courseList = courseList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Upload)) {
            return false;
        }
        Upload other = (Upload) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Upload[ id=" + id + " ]";
    }
    
}
